<?php

namespace App\Http\Controllers\Admin;

use App\Models\EmailSms;
use App\Models\PhoneSms;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Mail;
use Cloud;

/**
 * 验证码
 */
class SmsController extends Controller
{
    public function __construct()
    {
        view()->share('menu', 'sys');
    }

    public function index(Request $request)
    {
        $type = $request->get('type') ?? 1;
        $data = [];
        if ($type == 1) { //手机验证码
            $data = PhoneSms::orderby('created_at', 'desc')->paginate(10);
        } else {
            $data = EmailSms::orderby('created_at', 'desc')->paginate(10);
        }

        $page_num = $data->firstItem();

        return view('admin/sms/index', compact('data', 'type', 'page_num'));
    }
}
